#{extends 'main.html' /}
*{this is the page for the changing of role}*
    <script type="text/javascript" src="/public/javascripts/jquery.simpleMultiSelect.js"></script> 

    <script type="text/javascript"> 
      $(document).ready(function(){
        $('select#object_actions').simpleMultiSelect();
 
        $('a#none').click(function(){
            $('select#object_actions').smsNone();
        });
        $('a#all').click(function(){
            $('select#object_actions').smsAll();
        });
    });
    
  </script> 
        <link rel="stylesheet" type="text/css" media="screen" href="/public/stylesheets/crud.css" /> 
<body id="crud">
    <div id="crudContent"> 
        <h2>Create Project Role</h2>
        <input type="hidden" name="roleId" value="${roleId}" />
        <div class="objectForm"> 
            <div class="crudField"> 
                #{form @Projects.inheritCreateRole(name,roleId,inheritRole,projectId)}       
           
                    <label> 
                            Choose Role to inherit from:
                    </label>
                    <br>
    <select name="inheritRole">
    #{list items:rList, as:'inheritRole'}
        <option value="${inheritRole.id}">${inheritRole.title}</option> 
    #{/list}
    </select>
                  
                    <input type="submit" name="Inherit" value="Inherit" />
                #{/form}
                <br>
            </div>
            #{form @Projects.doneCreatingRole(projectId,name,action), id: 'createRole'}
                <div class="crudField"> 
                        <label for="object_title"> 
                            Title: <font color="red">*</font>
                        </label> 
                        <input class="validate[required]" type="text" name="name" id="name" ${isSystemRole ? 'disabled="true"' : ''} size="50"/>
                        <span class="crudHelp"> 
                            Required.
                        </span>
                </div>
                <br>
                <div class="crudField">     
                    <label for="object_actions"> 
                        Allowed Actions: <font color="red">*</font>
                    </label>
                    <div>
                        <select class="validate[required]" id="object_actions" name="action" multiple="yes">
 #{list items:allActions, as:'action'}
    #{list items:aSelList, as:'actionSel'}
    #{if action.id==actionSel.id}
    <input type="checkbox" value="${action.id}" id="actionId" name = "actionId">&nbsp;&nbsp;${action.name}<br/>
    <br/>
     </div>
     
    <option value="${action.id}" selected="true">${action.name}</option>
    %{flag = "true";}%
    #{/if}
    #{/list}
    #{if flag != "true"}
    <option value="${action.id}">${action.name}</option>
    #{/if}
    %{flag = "false";}%
    #{/list}
                        </select>
                    </div>
                    <span class="crudHelp">
                        At Least one Action is Required.
                    </span> 
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript: click()" id="none">None</a><b> | </b><a href="javascript: click()" id="all">All</a>
                </div>
                <br>
                <p class="crudButtons"> 
                    <input type="submit" value="Done"  />
                </p>
            #{/form}
            <p class="crudButtons" >
                #{form @Projects.getAllRoles(projectId)}
                    <div align="center">
                        <input type="submit" value="Back to Roles within this Project" /> 
                    </div>
                #{/form}
            </p>
        </div>
    </div>  
</body>
<script language = "JavaScript">
    $(function(){
        $('form').jqTransform({
            imgPath: 'public/stylesheets/img'
        });
    });
    
    $().ready(function(){
        $('#createRole').validationEngine()
    });
</script>